﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;

namespace UBCon.Ribbon
{
    public class ScrollViewerHelper : DependencyObject
    {
        /// <summary>
        /// Gets the value of the UBCon.Ribbon.ScrollViewerHelper.CanLineUp attached property for the 
        /// given dependency object.
        /// </summary>
        public static bool GetCanLineUp(DependencyObject obj)
        {
            return (bool)obj.GetValue(CanLineUpProperty);
        }

        /// <summary>
        /// Sets the value of the UBCon.Ribbon.ScrollViewerHelper.CanLineUp attached property for the 
        /// given dependency object.
        /// </summary>
        public static void SetCanLineUp(DependencyObject obj, bool value)
        {
            obj.SetValue(CanLineUpProperty, value);
        }

        /// <summary>
        /// Identifies UBCon.Ribbon.ScrollViewerHelper.CanLineUp attached property.
        /// </summary>
        public static readonly DependencyProperty CanLineUpProperty =
            DependencyProperty.RegisterAttached("CanLineUp", typeof(bool), typeof(ScrollViewerHelper), new PropertyMetadata(false));

        /// <summary>
        /// Gets the value of the UBCon.Ribbon.ScrollViewerHelper.CanLineDown attached property for the 
        /// given dependency object.
        /// </summary>
        public static bool GetCanLineDown(DependencyObject obj)
        {
            return (bool)obj.GetValue(CanLineDownProperty);
        }

        /// <summary>
        /// Sets the value of the UBCon.Ribbon.ScrollViewerHelper.CanLineDown attached property for the 
        /// given dependency object.
        /// </summary>
        public static void SetCanLineDown(DependencyObject obj, bool value)
        {
            obj.SetValue(CanLineDownProperty, value);
        }

        /// <summary>
        /// Identifies UBCon.Ribbon.ScrollViewerHelper.CanLineDown attached property.
        /// </summary>
        public static readonly DependencyProperty CanLineDownProperty =
            DependencyProperty.RegisterAttached("CanLineDown", typeof(bool), typeof(ScrollViewerHelper), new PropertyMetadata(false));

        /// <summary>
        /// Gets the value of the UBCon.Ribbon.ScrollViewerHelper.CanLineLeft attached property for the 
        /// given dependency object.
        /// </summary>
        public static bool GetCanLineLeft(DependencyObject obj)
        {
            return (bool)obj.GetValue(CanLineLeftProperty);
        }

        /// <summary>
        /// Sets the value of the UBCon.Ribbon.ScrollViewerHelper.CanLineLeft attached property for the 
        /// given dependency object.
        /// </summary>
        public static void SetCanLineLeft(DependencyObject obj, bool value)
        {
            obj.SetValue(CanLineLeftProperty, value);
        }

        /// <summary>
        /// Identifies UBCon.Ribbon.ScrollViewerHelper.CanLineLeft attached property.
        /// </summary>
        public static readonly DependencyProperty CanLineLeftProperty =
            DependencyProperty.RegisterAttached("CanLineLeft", typeof(bool), typeof(ScrollViewerHelper), new PropertyMetadata(false));

        /// <summary>
        /// Gets the value of the UBCon.Ribbon.ScrollViewerHelper.CanLineRight attached property for the 
        /// given dependency object.
        /// </summary>
        public static bool GetCanLineRight(DependencyObject obj)
        {
            return (bool)obj.GetValue(CanLineRightProperty);
        }

        /// <summary>
        /// Sets the value of the UBCon.Ribbon.ScrollViewerHelper.CanLineRight attached property for the 
        /// given dependency object.
        /// </summary>
        public static void SetCanLineRight(DependencyObject obj, bool value)
        {
            obj.SetValue(CanLineRightProperty, value);
        }

        /// <summary>
        /// Identifies UBCon.Ribbon.ScrollViewerHelper.CanLineRight attached property.
        /// </summary>
        public static readonly DependencyProperty CanLineRightProperty =
            DependencyProperty.RegisterAttached("CanLineRight", typeof(bool), typeof(ScrollViewerHelper), new PropertyMetadata(false));

        /// <summary>
        /// Gets the value of the UBCon.Ribbon.ScrollViewerHelper.Attach attached property for the 
        /// given dependency object.
        /// </summary>
        public static bool GetAttach(DependencyObject obj)
        {
            return (bool)obj.GetValue(AttachProperty);
        }

        /// <summary>
        /// Sets the value of the UBCon.Ribbon.ScrollViewerHelper.Attach attached property for the 
        /// given dependency object.
        /// </summary>
        public static void SetAttach(DependencyObject obj, bool value)
        {
            obj.SetValue(AttachProperty, value);
        }

        /// <summary>
        /// Identifies UBCon.Ribbon.ScrollViewerHelper.Attach attached property.
        /// </summary>
        public static readonly DependencyProperty AttachProperty =
            DependencyProperty.RegisterAttached("Attach", typeof(bool), typeof(ScrollViewerHelper), new PropertyMetadata(false, new PropertyChangedCallback(OnAttachPropertyChanged)));

        /// <summary>
        /// Gets the value of the UBCon.Ribbon.ScrollViewerHelper.ButtonWidth attached property for the 
        /// given dependency object.
        /// </summary>
        public static double GetButtonWidth(DependencyObject obj)
        {
            return (double)obj.GetValue(ButtonWidthProperty);
        }

        /// <summary>
        /// Sets the value of the UBCon.Ribbon.ScrollViewerHelper.ButtonWidth attached property for the 
        /// given dependency object.
        /// </summary>
        public static void SetButtonWidth(DependencyObject obj, double value)
        {
            obj.SetValue(ButtonWidthProperty, value);
        }

        /// <summary>
        /// Identifies UBCon.Ribbon.ScrollViewerHelper.ButtonWidth attached property.
        /// </summary>
        public static readonly DependencyProperty ButtonWidthProperty =
            DependencyProperty.RegisterAttached("ButtonWidth", typeof(double), typeof(ScrollViewerHelper), new PropertyMetadata(12.0D));

        
        private static ScrollViewer _scroller;

        private static void OnAttachPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            if ((bool)e.NewValue &&
                sender != null &&
                sender is ScrollViewer)
            {
                _scroller = sender as ScrollViewer;
            }
        }
    }
}

